# -*- coding: utf-8 -*-

import redis
import requests
import proxys

headers={
    'Accept-Language':'zh-CN,zh;q=0.9'
}

def get_url_requests(url,cookies):
    flag = 0
    while True:
        if flag>10:
            exit()
        try:
            proxy = {"http": proxys.get_proxy()}
            s = requests.session()
            s.keep_alive = False
            con = requests.get(url=url,cookies=cookies,proxies=proxy,timeout=10,headers=headers).text
            return con
        except Exception as err:
            flag += 1
            print(err)
            continue

def post_url_requests(url,cookies,headers,data):
    flag=0
    while True:
        if flag>10:
            exit()
        try:
            proxy = {"http": proxys.get_proxy()}
            s = requests.session()
            s.keep_alive = False
            con = requests.post(url=url, cookies=cookies, headers=headers,data=data,proxies=proxy,timeout=10).text
            return con
        except Exception as err:
            flag+=1
            print(err)
            continue